package com.bw.medical.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.bw.medical.vo.InquiryVos;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.bw.medical.entity.DockerLevelEntity;
import com.bw.medical.service.DockerLevelService;
import com.bw.common.utils.PageUtils;
import com.bw.common.utils.R;



/**
 * 医师表 
 *
 * @author wj
 * @email sunlightcs@gmail.com
 * @date 2021-08-22 21:39:10
 */
@RestController
@RequestMapping("/medical/tbdockerlevel")
public class DockerLevelController {
    @Autowired
    private DockerLevelService dockerLevelService;

    /**
     * 标签匹配医生列表
     * @param labels
     * @param page
     * @param limit
     * @return
     */
    @GetMapping("/doclist")
    public List<InquiryVos> doclist(@RequestParam("labels") String labels){
        List<InquiryVos> list=dockerLevelService.doclist(labels);
        return list;
    }
    /**
     * 医生列表
     */
     @RequestMapping("/lists")
    public R list(@RequestParam Map<String, Object> params){
        IPage<DockerLevelEntity> page = dockerLevelService.getLists(params);
        PageUtils pageUtils = new PageUtils(page.getRecords(), (int) page.getTotal(), (int) page.getSize(), (int) page.getPages());
        return R.ok().put("page", pageUtils);
    }
    //医生登级列表
    @RequestMapping("/info/{departmentId}")
    public R info(@PathVariable("departmentId")Integer departmentId){
        List<DockerLevelEntity> info = dockerLevelService.info(departmentId);
        return R.ok().put("data",info);
    }

    /**
     * 登录
     */
    //医生端登录
    @RequestMapping("login")
    public R list(@RequestParam("docterTell")String docterTell,@RequestParam("docterPwd")String docterPwd ){
        DockerLevelEntity login = dockerLevelService.login(docterTell, docterPwd);
        if (login==null){
            return R.ok().put("login", "flase");
        }
        else {
            return R.ok().put("login", login);
        }
    }
//
//    /**
//     * 信息
//     */
//    @RequestMapping("/info/{docterId}")
//    public R info(@PathVariable("docterId") Integer docterId){
//		DockerLevelEntity dockerLevel = dockerLevelService.getById(docterId);
//
//        return R.ok().put("dockerLevel", dockerLevel);
//    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody DockerLevelEntity dockerLevel){
		dockerLevelService.save(dockerLevel);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody DockerLevelEntity dockerLevel){
		dockerLevelService.updateById(dockerLevel);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] docterIds){
		dockerLevelService.removeByIds(Arrays.asList(docterIds));

        return R.ok();
    }

}
